    var LOADING_KEY = '_showLoading';

function setData(data) {
  var pages = getCurrentPages();
  return pages[pages.length - 1].setData(data);
}

function getData(key) {
  var pages = getCurrentPages();
  return pages[pages.length - 1].data[ket];
}

function showLoading() {
  var data = {};
  data[LOADING_KEY] = true;
  setData(data);
}

function hideLoading() {
  var data = {};
  data[LOADING_KEY] = false;
  setData(data);
}

function toggleLoading() {
  var isShowLoading = getData(LOADING_KEY);
  var data = {};
  data[LOADING_KEY] = !isShowLoading;
  setData(data);
}

var Loading = {
  show: showLoading,
  hide: hideLoading,
  toggle: toggleLoading
};


module.exports = Loading;